<?php
/**
 * Created by PhpStorm.
 * User: Kau
 * Date: 2018/3/20
 * Time: 1:20
 */
namespace app\common\model;


class Featured extends BaseModel
{

    /**
     * 根据类型获取列表数据
     * @param $type
     * @return array|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getFeaturedsByType($type)
    {
        $data = [
            'type' => $type,
            'status' => ['status', 'neq' , -1]
        ];
        $order = [
            'id' => 'desc'
        ];
        $result = $this->where($data)
            ->order($order)
            ->paginate();

        return $result;
    }

    /**
     * @param $type 0 大图 1 右侧
     * @return array|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getFeatured($type)
    {
        $data = [
            'type' => $type,
            'status' => ['status', '=' , 1]
        ];
        $order = [
            'id' => 'desc'
        ];
        $result = $this->where($data)
            ->order($order)
            ->select();

        return $result;
    }


}